package com.bruce.codeFactory.jdk;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * @author luotuan
 * @Description
 * @create 2019-03-05 13:12
 **/
public class ListRemoveDemo {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for(int i=0;i<4000000;i++){
            list.add(i);
        }
        long start = System.currentTimeMillis();
        remove(list);
        long end = System.currentTimeMillis();
        System.out.println("The method run time is :"+(end-start));
    }
    public static void remove(List<Integer> target) {
        for (Iterator<Integer> iterator = target.iterator(); iterator.hasNext(); ) {
            if (iterator.next() % 2 == 0) {
                iterator.remove();
            }
        }
    }
}
